package com.sts.transform.function;

import com.github.yitter.contract.IdGeneratorOptions;
import com.github.yitter.idgen.YitIdHelper;
import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.type.AviatorBigInt;
import com.googlecode.aviator.runtime.type.AviatorObject;

import java.util.Map;

/**
 * @author lsl
 * @since 2025年07月08日 19:24
 */
public class IDFunction extends AbstractFunction {

    static {
        IdGeneratorOptions options = new IdGeneratorOptions();
        YitIdHelper.setIdGenerator(options);
    }

    @Override
    public AviatorObject call(Map<String, Object> env) {
        return new AviatorBigInt(YitIdHelper.nextId());
    }

    @Override
    public String getName() {
        return "id";
    }
}
